﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronCommander.Utils
{
    public static class If
    {
        public static If<T> Value<T>(T value)
        {
            return new If<T>(value);
        }
    }

    public class If<T>
    {
        readonly T value;

        public If(T value)
        {
            this.value = value;
        }

        public void HasType<TType>(Action<TType> action)
        {
            if (value is TType)
                action((TType)(object)value);
        }

        public void IsNotNull(Action<T> action)
        {
            if (!EqualityComparer<T>.Default.Equals(default(T), value))
                action(value);
        }
    }
}
